; If you meet compile error, try 'sudo apt install gcc-multilib g++-multilib' first

%include "head.include"
; you code here

your_if:
; put your implementation here
  mov eax, dword[a1]
  cmp eax, 12 ;a1<12
  jl less_than_12
  
  cmp eax, 24
  jl less_than_24 ;a1<24
  
  shl eax, 4 ;a1 << 4
  jmp end_if
  
less_than_12:
  ; if_flag = a1/2+1
  shr eax, 1
  inc eax
  mov dword[if_flag], eax
  jmp end_if
  
less_than_24:
  mov ebx, 24
  sub ebx, eax
  imul eax, ebx
  mov dword[if_flag], eax
  
end_if:
  mov dword[if_flag], eax

your_while:
; put your implementation here
  mov ebx, dword[a2] ; ebx = a2
  cmp ebx, 12 ; while a2 >= 12
  jl end_while
  
  call my_random ;my_random产生随机数放入eax
  mov ecx, [while_flag] ;address
  mov esi, ebx ; a2
  mov byte[ecx+esi-12], al ;8 bits
  dec dword[a2] ; --a2
  mov ebx, dword[a2]
  jmp your_while
  
end_while:
  

%include "end.include"

your_function:
; put your implementation here
  mov esi, 0 ;i
  mov edx, [your_string] ;address
  
loop:
  mov  al, byte[edx+esi] ;8 bits only
  cmp al, 0
  je end

  pushad
  
  push eax ; into stack
  call print_a_char
  add esp, 4 ; pop
  
  popad
  
  inc esi ; ++i
  jmp loop
  
end:
  ret

